Save 20~30 minutes on every shared memory run. #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addition to the code modifies the behavior of the multiprocessing.resource_tracker module in Python. It applies a monkey patch to ensure that the SharedMemory resource type is not tracked by the resource tracker.
The purpose of this modification is to prevent the training and validation language episodes from being removed from memory each time. By allowing these episodes to persist in memory, the code can save a significant amount of time, approximately 20 to 30 minutes, in each run.
The modification achieves this by overriding the register and unregister functions of the resource tracker. When a resource type is "shared_memory," these functions return None, effectively skipping the registration and unregistration process.
Additionally, the modification removes the "shared_memory" entry from the _CLEANUP_FUNCS dictionary of the resource tracker. This ensures that the cleanup function for shared memory is not called.
By making these changes, the code avoids the unnecessary overhead of reloading the training and validation language episodes, resulting in a considerable time-saving benefit during execution.